diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td
--- a/mlir/examples/toy/Ch2/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch2/include/toy/Ops.td
@@ -222,7 +222,7 @@
 
   // Provide extra utility definitions on the c++ operation class definition.
   let extraClassDeclaration = [{
-    bool hasOperand() { return getNumOperands() != 0; }
+    bool hasOperand() const { return getNumOperands() != 0; }
   }];
 
   // Invoke a static verify method to verify this return operation.
diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td
--- a/mlir/examples/toy/Ch3/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch3/include/toy/Ops.td
@@ -224,7 +224,7 @@
 
   // Provide extra utility definitions on the c++ operation class definition.
   let extraClassDeclaration = [{
-    bool hasOperand() { return getNumOperands() != 0; }
+    bool hasOperand() const { return getNumOperands() != 0; }
   }];
 
   // Invoke a static verify method to verify this return operation.
diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td
--- a/mlir/examples/toy/Ch4/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch4/include/toy/Ops.td
@@ -250,7 +250,7 @@
 
   // Provide extra utility definitions on the c++ operation class definition.
   let extraClassDeclaration = [{
-    bool hasOperand() { return getNumOperands() != 0; }
+    bool hasOperand() const { return getNumOperands() != 0; }
   }];
 
   // Invoke a static verify method to verify this return operation.
diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td
--- a/mlir/examples/toy/Ch5/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch5/include/toy/Ops.td
@@ -251,7 +251,7 @@
 
   // Provide extra utility definitions on the c++ operation class definition.
   let extraClassDeclaration = [{
-    bool hasOperand() { return getNumOperands() != 0; }
+    bool hasOperand() const { return getNumOperands() != 0; }
   }];
 
   // Invoke a static verify method to verify this return operation.
diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td
--- a/mlir/examples/toy/Ch6/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch6/include/toy/Ops.td
@@ -251,7 +251,7 @@
 
   // Provide extra utility definitions on the c++ operation class definition.
   let extraClassDeclaration = [{
-    bool hasOperand() { return getNumOperands() != 0; }
+    bool hasOperand() const { return getNumOperands() != 0; }
   }];
 
   // Invoke a static verify method to verify this return operation.
diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td
--- a/mlir/examples/toy/Ch7/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch7/include/toy/Ops.td
@@ -265,7 +265,7 @@
 
   // Provide extra utility definitions on the c++ operation class definition.
   let extraClassDeclaration = [{
-    bool hasOperand() { return getNumOperands() != 0; }
+    bool hasOperand() const { return getNumOperands() != 0; }
   }];
 
   // Invoke a static verify method to verify this return operation.